package cn.itcast.itcaststore.web.servlet;

import cn.itcast.itcaststore.domain.User;
import cn.itcast.itcaststore.service.Impl.IOrderService;
import cn.itcast.itcaststore.service.OrderService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/OrderListServlet")
public class OrderListServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = (User) request.getSession().getAttribute("user");
        OrderService iOrderService = new IOrderService();
        List list=iOrderService.getOrderList(user.getUsername());

        request.setAttribute("orders",list );
        request.getRequestDispatcher("/client/orderlist.jsp").forward(request,response );
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
